package com.bwie.controller;

import com.bwie.pojo.TbOrder;
import com.bwie.service.OrderService;
import com.bwie.utils.R;
import com.bwie.vo.EsOrder;
import com.bwie.vo.PageVo;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Title:
 * @BelongProjecet practice2
 * @BelongPackage com.bwie.controller
 * @Description:
 * @Copyright 研发一部
 * @Author: Mr.yan
 * @Date: 2024/6/7 10:05
 * @Version V1.0
 */
@RestController
@RequestMapping(value = "/order/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/7 10:08
     * @param: 图片上传
     * @param file
     * @return com.bwie.utils.R
     */
    @PostMapping("/uploadFile")
    public R uploadFile(
            @RequestPart(name = "file")MultipartFile file
            ){
        return orderService.uploadFile(file);
    }

    /***
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/7 10:59
     * @param: 创建es索引和映射
     * @return com.bwie.utils.R
     */
    @PostMapping("/createIndex")
    public R createIndex(){
        return orderService.createIndex();
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/7 11:48
     * @param: 展示订单列表，高亮，分页，查询，区间查询
     * @param pageVo
     * @return com.bwie.utils.R
     */
    @PostMapping("/esOrderList")
    public R esOrderList(
            @RequestBody PageVo pageVo
            ){
        return orderService.esOrderList(pageVo);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/7 14:57
     * @param: 创建订单详情
     * @param tbOrder
     * @return com.bwie.utils.R
     */
    @PostMapping("/addOrder")
    public R addOrder(
            @RequestBody TbOrder tbOrder
            ){
        return orderService.addOrder(tbOrder);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/11 19:23
     * @param: 根据订单id查询订单详情
     * @param id
     * @return com.bwie.utils.R
     */
    @PostMapping("/orderDetails/{id}")
    public R orderDetails(
            @PathVariable Integer id
    ){
        return orderService.orderDetails(id);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/11 21:06
     * @param: 批量删除
     * @param tbOrderList
     * @return com.bwie.utils.R
     */
    @PostMapping("/deleteOrder")
    public R deleteOrder(
            @RequestBody List<TbOrder> tbOrderList
            ){
        return orderService.deleteOrder(tbOrderList);
    }

    @PostMapping("/addShip")
    public R addShip(
            @RequestBody TbOrder tbOrder
    ){
        return orderService.addShip(tbOrder);
    }

    @PostMapping("/practice")
    public R addPractice(
            @RequestBody TbOrder tbOrder
    ){
        return orderService.addPractice(tbOrder);
    }
    @PostMapping("/showPhoto")
    public R showPhoto(){
        return orderService.showPhoto();
    }


}
